<?php if (!defined('THINK_PATH')) exit();?><div class="bjui-pageHeader">
    <div class="pull-right">
        <button class="btn-default" data-icon="plus" title="新增产品" data-toggle="tooltip" data-placement="left" onclick="createNavtab('<?php echo U("Forms/pro", array('item'=>'1'));?>', '新增商品', 'pro')" ></button>
        <button class="btn-default" data-icon="refresh" onclick="$.CurrentNavtab.navtab('refresh')"></button>
    </div>
    <form id="pagerForm" data-toggle="ajaxsearch" data-loadingmask="true" action="<?php echo U('index');?>" method="post">
        <input type="hidden" name="pageSize" value="<?php echo I('param.pageSize');?>" />
        <input type="hidden" name="pageCurrent" value="<?php echo I('param.pageCurrent');?>" />
        <input type="hidden" name="orderField" value="<?php echo I('param.orderField');?>" />
        <input type="hidden" name="orderDirection" value="<?php echo I('param.orderDirection');?>" />
        <div class="bjui-searchBar">
            <label>所有分类:</label>
            <select name="class_id" data-toggle="selectpicker">
                <option value="0">--请选择--</option>
                <?php if(is_array($res)): $i = 0; $__LIST__ = $res;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($vo["id"]); ?>" <?php if(I('class_id') == $vo['id']): ?>selected<?php endif; ?>><?php echo ($vo["name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
            </select>
            <label>品牌:</label>
            <select name="brandid" data-toggle="selectpicker">
                <option value="0">--请选择--</option>
                <?php if(is_array($brandlist)): $i = 0; $__LIST__ = $brandlist;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$bo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($bo["id"]); ?>" <?php if(I('brandid') == $bo['id']): ?>selected<?php endif; ?>><?php echo ($bo["name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
            </select>
            <label>状态:</label>
            <select name="status" data-toggle="selectpicker">
                <option value="">--请选择--</option>
                <option value="0" <?php if(I('status') == '0'): ?>selected<?php endif; ?>>上架</option>
                <option value="1" <?php if(I('status') == '1'): ?>selected<?php endif; ?>>下架</option>
            </select>
            <label>类型:</label>
            <select name="commend_id" data-toggle="selectpicker">
                <option value="1">--请选择--</option>
                <?php if(is_array($commend)): $i = 0; $__LIST__ = $commend;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$co): $mod = ($i % 2 );++$i;?><option value="<?php echo ($co["id"]); ?>" <?php if(I('commend_id') == $co['id']): ?>selected<?php endif; ?>><?php echo ($co["name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
            </select>
            <label>名称:</label>
            <input type="text" name="name" value="<?php echo I('name');?>" />
            <button type="submit" class="btn-default" data-icon="search">查询</button>
            <a class="btn btn-orange" href="javascript:;" data-toggle="reloadsearch" data-clear-query="true" data-icon="undo">清空查询 </a>
        </div>
    </form>
</div>
<div class="bjui-pageContent tableContent">
    <table class="table table-bordered table-hover table-striped table-top prolist" data-selected-multi="false" >
        <thead>
        <tr>
            <th width="40">NO.</th>
            <th>商品名称</th>
            <th>所属类型</th>
            <th>所属商家</th>
            <th>货号</th>
            <th>分类</th>
            <th width="120">价格</th>
            <th width="70">是否上架</th>
            <th width="70">权重</th>
            <!-- <th width="70">查看库存</th> -->
            <th width="140">操作</th>
        </tr>
        </thead>
        <tbody>
        <!--data-id === 商品ID,修改库存,权重时调用-->
        <?php if(is_array($list)): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><tr data-id="<?php echo ($vo["id"]); ?>">
            <td><?php echo ($vo["id"]); ?></td>
            <td><a href="javascript:void(0)" target="_blank"><?php echo ($vo["name"]); ?></a></td>
            <td><?php echo ($vo["commend_name"]); ?></td>
            <td><?php echo ($vo["shop_name"]); ?></td>
            <td><?php echo ($vo["goods_no"]); ?></td>
            <td><?php echo goods_class($vo['id'],",");?></td>
            <td><?php echo goods_price($vo['id']);?>元</td>
            <?php if($vo["status"] == '0'): ?><td><a href="<?php echo U('Forms/update_goods_status',array('id'=>$vo['id']));?>" data-type="get" data-toggle="doajax" data-confirm-msg="确定要下架这个商品吗??">是</a></td>
            <?php else: ?>
            <td><a href="<?php echo U('Forms/update_goods_status',array('id'=>$vo['id']));?>" data-type="get" data-toggle="doajax" data-confirm-msg="确定要上架这个商品吗??">否</a></td><?php endif; ?>
            <td class="prolist"><input type="text" value="<?php echo ($vo["sort"]); ?>" maxlength="3" style="width:40" data-type="sort"/></td>
            <!-- <td><button type="button" class="btn-green" onclick="createNavtab('<?php echo U("Forms/pro_pro",array('id'=>$vo["id"]));?>', '查看库存', 'pro_pro')">查看库存</button></td> -->
            <td>
                <!-- <a href="/Site/item/goodid/<?php echo ($vo["id"]); ?>_<?php echo ($vo["product_id"]); ?>" target="_blank" class="btn btn-blue">看</a> -->
                <button type="button" class="btn-green"  onclick="createNavtab('<?php echo U("Forms/pro",array('id'=>$vo["id"]));?>', '编辑商品', 'pro')">改</button>
                <a href="<?php echo U('Forms/del_goods',array('id'=>$vo['id']));?>" data-type="get" class="btn btn-red" data-toggle="doajax" data-confirm-msg="要删除这个商品??" >删</a>
            </td>
        </tr><?php endforeach; endif; else: echo "" ;endif; ?>
        </tbody>
    </table>
</div>
<script>
    $(function () {
        $('.prolist input[type=text]').keyup(function () {
            var v = $(this).val(),
                    type = $(this).attr('data-type'),
                    pid = $(this).parents('tr').attr('data-id');
           $(this).bjuiajax('doAjax', {
              url:'<?php echo U("Forms/sort_goods");?>',
               type:'post',
               data:{val: v, id : pid,type:type},
               loadingmask:false,
               callback:function (json) {
                   if (json[BJUI.keys.statusCode] != BJUI.keys.statusCode){
                        $(this).bjuiajax('ajaxDone', json);
                   }
                   return false;
               }
           });
        });
    });

</script>


<div class="bjui-pageFooter">
		
	<?php if(page == save): ?><ul>
			<li><button type="submit" class="btn-default" data-icon="save">保存</button></li>
	        <li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
	    </ul>
	<?php elseif(page == close): ?>
	    <ul>
	        <li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
	    </ul>
	<?php elseif(page == page and $show != null): ?>
		<ul>
	        <li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
	    </ul>
		    <div class="pages">
		        <span>每页&nbsp;</span>
		        <div class="selectPagesize">
		            <select data-toggle="selectpicker" data-toggle-change="changepagesize">
		                <option value="<?php echo ($show['listrow']); ?>"><?php echo ($show['listrow']); ?></option>
		                <option value="60">60</option>
		                <option value="120">120</option>
		                <option value="150">150</option>
		            </select>
		        </div>
		        <span>&nbsp;条，共 <?php echo ($show['total']); ?> 条</span>
		    </div>
		    <div class="pagination-box" data-toggle="pagination" data-total="<?php echo ($show['total']); ?>" data-page-size="<?php echo ($show['listrow']); ?>" data-page-current="1">
		    </div>
	<?php elseif(page == page and $show == null): ?>
		<ul>
			<li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
		</ul>
	<?php else: ?>
		<ul>
			<li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
		</ul><?php endif; ?>

</div>